library(ggplot2)
SNPs<- read.table("23andMe_complete.txt", header = TRUE, sep = "\t")
ggplot(data = SNPs) +
geom_bar(mapping = aes(x=SNPs$chromosome), fill="blue") +
ggtitle("SNP Counts for Each Chromosome") +
scale_x_discrete(name="Chromosome Number") +
scale_y_continuous(name="SNP Count")
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
genotypecolors <-c("AA"="blue", "AC"="blue", "AG"="blue", "AT"="blue", "CC"="blue", "CG"="blue", "CT"="blue", "GG"="blue", "GT"="blue", "TT"="blue", "A"="red", "C"="red", "G"="red", "T"="red", "D"="green", "DD"="green", "DI"="green", "DI"="green","I"="green", "II"="green")
ggplot(data = SNPs) +
geom_bar(mapping = aes(x=SNPs$chromosome, fill=SNPs$genotype)) +
ggtitle("Contribution of each Genotype to Total SNP Count") +
scale_x_discrete(name="Chromosome Number") +
scale_y_continuous(name="SNP Count") +
scale_fill_manual(values= genotypecolors)
Genotype counts per chromosome
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
ggplot(data = SNPs) +
geom_bar(mapping = aes(x= chromosome, fill= genotype), position = "dodge") +
facet_wrap(~genotype, ncol= 2) +
scale_x_discrete(name= "chromosome number") +
scale_y_continuous(name= "Number of SNPs") +
ggtitle("Genotype Levels in Each Chromosome")
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1,22), "X", "Y", "MT"))
ggplotly(
ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill = genotype), position = "dodge") +
facet_wrap(~genotype, nrow = 2)
)
YSNP <- subset(SNPs, chromosome=="Y")
library(DT)
datatable(YSNP)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html